package com.yq.backend.service.impl;

import com.yq.backend.mapper.SysOplogMapper;
import com.yq.backend.pojo.CardGame;
import com.yq.backend.pojo.Result;
import com.yq.backend.pojo.SysOplog;
import com.yq.backend.service.SysLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @descriptions:
 * @author: yunqiang
 * @date: 2022/5/3 14:49
 */
@Slf4j
@Service
public class SysLogServiceImpl implements SysLogService {

    @Autowired
    private SysOplogMapper sysOplogMapper;

    @Override
    public Result getLods(SysOplog sysOplog, int pageSize, int pageNow) {

        if (pageNow > 0){
            pageNow  =(pageNow - 1)*pageSize;
        }else{
            pageNow = 0;
        }
        long total = sysOplogMapper.getLodsCount(sysOplog);
        List<CardGame> cardGames = sysOplogMapper.getLods(sysOplog,pageNow,pageSize);
        if(CollectionUtils.isEmpty(cardGames)){
            return Result.noResult();
        }
        return Result.success(total,cardGames);
    }
}
